package controller

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

type BaseController struct{}

func (c *BaseController) Success(ctx *gin.Context, data any) {
	ctx.JSON(http.StatusOK, gin.H{
		"code":    20000,
		"message": "success",
		"data":    data,
	})
}

func (c *BaseController) Error(ctx *gin.Context, err error) {
	ctx.JSON(http.StatusOK, gin.H{
		"code":    50000,
		"message": err.Error(),
		"data":    nil,
	})
}
